import axios from "../axios";

// Demand Api

// getDeamd 根据ID获取招聘需求
export const getDeamd = ({ id }) => {
  return axios.request({
    url: `/demand/${id}`,
    method: "get",
  });
};

// insert demand 新增招聘需求
export const insertDemand = (params) => {
  const data = {
    demandCode: params.demandCode, // 需求编码
    id: params.id, // 主键
    introduction: params.introduction, // 需求简介
    peopleNumber: params.peopleNumber, // 需求人数
    projectId: params.projectId, // 项目ID
    skill: params.skill, // 技能（string）
    skillLevel: params.skillLevel, // 技能级别 （string）
    workPlace: params.workPlace, // 需求地点
  };
  return axios.request({
    url: "/demand/insert",
    data,
    method: "post",
  });
};

// pageDeamd 分页查询
export const getDeamd = (params) => {
  const data = {
    delFlag: params.delFlag,
    demandCode: params.demandCode,
    pageNumber: params.pageNumber,
    pageSize: params.pageSize,
    projectId: params.projectId,
    skill: params.skill,
    skillLevel: params.skillLevel,
    workPlace: params.workPlace,
  };
  return axios.request({
    url: "/demand/page",
    params: data,
    method: "get",
  });
};

// recoveryDemand 恢复招聘需求
export const recoveryDemand = (params) => {
  const { id } = params;
  return axios.request({
    url: `/demand/recovery/${id}`,
    method: "put",
  });
};

// update demand 更新招聘需求
export const updateDemand = (params) => {
  const data = {
    demandCode: params.demandCode, // 需求编码
    id: params.id, // 主键
    introduction: params.introduction, // 需求简介
    peopleNumber: params.peopleNumber, // 需求人数
    projectId: params.projectId, // 项目ID
    skill: params.skill, // 技能（string）
    skillLevel: params.skillLevel, // 技能级别 （string）
    workPlace: params.workPlace, // 需求地点
  };
  return axios.request({
    url: "/demand/update",
    data,
    method: "put",
  });
};
